package cn.elricyu.tt.action.tech;

import net.sf.json.JSON;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.elricyu.tt.action.base.AbstractAction;
import cn.elricyu.tt.bean.ResultStatus;
import cn.elricyu.tt.bean.User;
import cn.elricyu.tt.bean.officer.MyOfficer;
import cn.elricyu.tt.bean.tech.MyTech;
import cn.elricyu.tt.util.JsonUtil;

public class TechUpgradeAction extends AbstractAction<MyOfficer> {
	private static Log logger = LogFactory.getLog(TechUpgradeAction.class);
	private User self = null;

	public TechUpgradeAction(User self, String techId) {
		this.self = self;
		this.url = "root/tech!upgradeTech.action";
		this.postDataMap.put("techId", techId);
	}

	public void process(JSON json) {
		int state = JsonUtil.getIntValue(json, "state", 0);
		if (ResultStatus.SUCCESS.getCode() == state) {
			MyTech myTech = self.getMyTech();
			if (myTech == null) {
				myTech = new MyTech();
				self.setMyTech(myTech);
			}
			TechMainAction.doParseAll(myTech, json);
		}
	}
}
